package com.base.system.exception.handler;

import com.base.system.base.http.HttpResult;
import com.base.system.exception.HttpException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 全局异常捕获
 */
@ControllerAdvice
@Slf4j
public class GloablExceptionHandler {
    @ResponseBody
    @ExceptionHandler({Exception.class})
    public HttpResult<HttpException> handleException(HttpException e) {
        log.error("全局异常捕获:{}", e);
        return HttpResult.faild(e);
    }
}
